<?php
$modelEntity = new RedSocial('search');
$modelEntity->unsetAttributes();
$modelEntity->entidad_tipo = Crm_Constants::ENTIDAD_TIPO_CONTACTO;
$modelEntity->entidad_id = $model->id ? $model->id : 0;
$dataProvider = $modelEntity->search();
$fData = $dataProvider->getData();
?>
<?php
$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
    'type' => 'horizontal',
    'id' => 'red-social-form',
    'enableAjaxValidation' => false,
    'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false,),
    'enableClientValidation' => true,
        ));
?>
<div class="widget blue">
    <div class="widget-title">
        <h4><i class="icon-facebook-sign"></i> Redes Sociales</h4>
<!--        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
        </span>-->
    </div>
    <div class="widget-body">
        <div class="row-fluid">
            <input id="isNewRecord" value="<?php echo $modelEntity->isNewRecord ? 1 : 0 ?>" type="hidden">
            <?php echo $form->textFieldRow($modelEntity, 'valor', array('maxlength' => 100)) ?>


            <?php echo $form->dropDownListRow($modelEntity, 'tipo', array('FACEBOOK' => 'FACEBOOK', 'TWITTER' => 'TWITTER', 'GOOGLE PLUS' => 'GOOGLE PLUS', 'PINTEREST' => 'PINTEREST',)) ?>
            <label class="control-label required" for="medio">Principal </label>
            <div class="controls">
                <?php
                $this->widget(
                        'ext.bootstrap.widgets.TbToggleButton', array(
                    'model' => $modelEntity,
                    'disabledLabel' => 'NO',
                    'enabledLabel' => 'SI',
                    'width' => 150,
                    'enabledStyle' => 'primary',
                    'disabledStyle' => 'warning',
                    'attribute' => 'principal',
                        )
                );
                ?>
            </div>
            <?php echo $form->hiddenField($modelEntity, 'entidad_tipo') ?>
            <?php echo $form->hiddenField($modelEntity, 'entidad_id') ?>
        </div>
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'type' => 'success',
            'icon' => 'ok',
            'label' => $modelEntity->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
            'htmlOptions' => array(
                'onClick' => 'js:saveRedSocial("#red-social-form")')
        ));
        ?>
        <div class="space12"></div>
        <div id="container_redsocial" style='overflow:auto'> 
            <?php
            $this->widget('ext.bootstrap.widgets.TbGridView', array(
                'id' => 'redsocial-grid',
                'type' => 'striped bordered hover advance',
                'dataProvider' => $dataProvider,
                'columns' => array(
                    array(
                        'header' => 'Dirección',
                        'name' => 'valor',
                        'type' => 'raw',
                    ),
                    'tipo',
                    array(
                        'name' => 'principal',
                        'value' => '$data->principal==1?"<i class=\"icon-check\"></i>":""',
                        'type' => 'raw',
                    ),
                    array(
                        'class' => 'CButtonColumn',
                        'template' => '{update} {delete}',
                        'buttons' => array(
                            'update' => array(
                                'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                                'options' => array('title' => 'Actualizar'),
                                'imageUrl' => false,
                                'url' => '$data->id',
                                'click' => 'function() {formModalRedSocial(true, $(this).attr("href")); return false;}',
                                'visible' => 'Util::checkAccess(array("action_redSocial_quickUpdate"))',
                            ),
                            'delete' => array(
                                'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                                'options' => array('title' => 'Eliminar'),
                                'url' => 'Yii::app()->createUrl("crm/redSocial/delete", array("id"=>$data->id))',
                                'imageUrl' => false,
                                'visible' => 'Util::checkAccess(array("action_redSocial_delete"))',
                            ),
                        ),
                        'htmlOptions' => array(
                            'width' => '80px'
                        )
                    ),
                ),
            ));
            ?>
        </div>
    </div>
</div>
<?php $this->endWidget(); ?>